﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;

namespace WCS.Infrastructure.EFCore;

/// <summary>
/// 分账记录详情表
/// </summary>
[Table("DividedRecordDetail")]
[Index("DividedRecordId", Name = "DividedRecordDetail_DividedRecordId_idx")]
[Index("UserId", Name = "DividedRecordDetail_UserId_idx")]
[Index("DividedRecordId", "LayerAgreementId", Name = "IX_DividedRecordDetail_DividedRecordId_LayerAgreementId")]
[Index("RootAgreementId", Name = "IX_DividedRecordDetail_RootAgreementId")]
[Index("UserId", Name = "IX_DividedRecordDetail_UserId")]
public partial class DividedRecordDetail
{
    /// <summary>
    /// 分账记录详情ID
    /// </summary>
    [Key]
    [StringLength(32)]
    public string Id { get; set; } = null!;

    /// <summary>
    /// 分账记录ID
    /// </summary>
    [StringLength(32)]
    public string DividedRecordId { get; set; } = null!;

    /// <summary>
    /// 分账接收方用户ID
    /// </summary>
    [StringLength(32)]
    public string UserId { get; set; } = null!;

    /// <summary>
    /// 分账比例
    /// </summary>
    public decimal Ratio { get; set; }

    /// <summary>
    /// 分账金额
    /// </summary>
    public long DividedAmount { get; set; }

    /// <summary>
    /// 创建时间
    /// </summary>
    [Column(TypeName = "timestamp(6) without time zone")]
    public DateTime CreationTime { get; set; }

    /// <summary>
    /// 入账时间
    /// </summary>
    [Column(TypeName = "timestamp(6) without time zone")]
    public DateTime? EntryTime { get; set; }

    /// <summary>
    /// 是否入账
    /// </summary>
    public bool IsEntry { get; set; }

    /// <summary>
    /// 是否是主账户
    /// </summary>
    public bool IsMasterAccount { get; set; }

    /// <summary>
    /// 根层协议ID（分账溯源用）
    /// </summary>
    public string? RootAgreementId { get; set; }

    /// <summary>
    /// 有效层协议ID（当前分账详情所处层）
    /// </summary>
    public string? LayerAgreementId { get; set; }

    /// <summary>
    /// 从根到叶的分账路径(JSON：协议ID与比例序列)
    /// </summary>
    public string? PathJson { get; set; }

    /// <summary>
    /// 路径深度（层数）
    /// </summary>
    public int? PathDepth { get; set; }

    /// <summary>
    /// 路径包含协议数量
    /// </summary>
    public int? PathAgreementCount { get; set; }
}
